package com.bw.mvvm_common.mvvm.model;

import com.bw.mvvm_common.entity.BaseEntity;
import com.bw.mvvm_common.network.ChangeFunction;
import com.google.gson.Gson;

import java.util.HashMap;

import io.reactivex.Observable;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * @author KK
 * @description:
 * @date :2021/10/12 15:01
 */
public abstract class BaseModel implements IModel {
    @Override
    public RequestBody createBody(HashMap<String, Object> map) {
        return RequestBody.create(MediaType.parse("application/json"),new Gson().toJson(map));
    }

    @Override
    public Observable<BaseEntity> changeFunc(Observable<? extends BaseEntity> observable) {
        return observable.map(new ChangeFunction<>());
    }
}
